public class VariableArgumentsDemo 
{
public static double add(double... num)
{
double sum=0;
for(int i=0; i<num.length;i++)
{
sum=sum+num[i];
}
return sum;
}

public static void main(String[] args)
{
int iSum=(int) VariableArgumentsDemo.add(12,245,345);
float fSum=(float) VariableArgumentsDemo.add(1.1f,2.2f,5.1f,90,6f);
double allSum = VariableArgumentsDemo.add(20,25,70,7f,90,90,8989,9090987);
System.out.println("Integer addition:"+iSum);
System.out.println("Float addition:"+fSum);
System.out.println("Mixed addition:"+allSum);
}
}